# list
classmates = ['张三', 'Francis', "WangZhen"]
print(classmates)
print(len(classmates))
print(classmates[0])
# print(classmates[3])
print(classmates[-1])
print(classmates[-2])

# 追加
classmates.append('Zhao Enjing')
print(classmates)
classmates.insert(-2, '')
print(classmates)
classmates.pop()
print(classmates)
classmates.pop(2)
print(classmates)
classmates[2] = 25.6
print(classmates)

# 列表嵌套
listList = ['Jay Chow', ['透心凉, 心飞扬', '银鹭花生牛奶'], 'JJ Lin']
print(listList)
print(len(listList))
print('------------ START 这里是嵌套列表 - 存取单值 START ------------')
print(listList[0])
print(listList[1])
print(listList[1].append('Nihao'))
print(listList)
print(listList[2])
listList[1][1] = 'abc'
print(listList)
print('------------ END 这里是嵌套列表 - 存取单值 END ------------')

subList = ['透心凉, 心飞扬', '银鹭花生牛奶']
baseList = ['Jay Chow', subList, 'JJ Lin']
print(baseList)
print(len(baseList))

emptyList = []
print(emptyList)
print(len(emptyList))


# tuple
print('------------ 元组 ------------')
# tuple一旦初始化就不能修改
classmate = ('Michael', 'Bob', 'Alice')
print(classmate)
emptyTuple = ()
print(emptyTuple)
# 以下情况会按数学中的小括号处理
classmate = (1)
print(classmate)
# 所以，定义只有一个元素的tuple时，要加逗号消除歧义
classmate = (1,)
# python在显示只有一个元素的tuple时，也会加一个逗号来消除歧义
print(classmate)


# 练习
L = [
    ['Apple', 'Google', 'Microsoft'],
    ['Java', 'Python', 'Ruby', 'PHP'],
    ['Adam', 'Bart', 'Lisa']
]
print(L[0][0])
print(L[1][1])
print(L[2][2])
